﻿<ResourceDictionary
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	mc:Ignorable="d"
    xmlns:doc="http://schemas.firstfloorsoftware.com/documenttoolkit"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <!-- Global Settings-->
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Brushes.xaml"/>
        <ResourceDictionary Source="Fonts.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="doc:DocumentViewer">
        <Setter Property="Background" Value="{StaticResource NormalBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource SliderTrackBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="doc:DocumentViewer">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                        <ScrollViewer x:Name="ScrollViewer" Background="Transparent" BorderThickness="0" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                            <ItemsControl x:Name="Pages">
                                <i:Interaction.Behaviors>
                                    <doc:PageVirtualizer />
                                </i:Interaction.Behaviors>
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <Grid Width="{Binding DesiredPageContainerSize.Width}"
                                          Height="{Binding DesiredPageContainerSize.Height}">
                                            <Border Background="White" BorderBrush="{StaticResource SliderTrackBrush}" BorderThickness="1" Margin="4" HorizontalAlignment="Center" VerticalAlignment="Center">
                                                <doc:FixedPageViewer FixedPage="{Binding FixedPage}" 
                                                                     FixedPageSize="{Binding FixedPageSize}"
                                                                     FixedPageError="{Binding FixedPageError}"
                                                                     Scale="{Binding DesiredPageScale}">
                                                    <i:Interaction.Behaviors>
                                                        <doc:FixedPageAdorner Annotations="{Binding TextContainer.Annotations}" Selection="{Binding TextContainer.Selection}" />
                                                        <doc:NavigationBehavior TextContainer="{Binding TextContainer}" />
                                                    </i:Interaction.Behaviors>
                                                </doc:FixedPageViewer>
                                            </Border>
                                        </Grid>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <DataTemplate x:Key="ThumbnailTemplate">
        <Grid Margin="4" HorizontalAlignment="Center">
            <Border Background="White" BorderBrush="{StaticResource SliderTrackBrush}" BorderThickness="1">
                <Image Source="{Binding FixedPageThumbnail}" />
            </Border>
            <TextBlock Text="{Binding PageContent.PageNumber}"
                       FontFamily="{StaticResource HeaderFontFamily}"
                       FontSize="{StaticResource HeaderFontSize}"
                       Foreground="{StaticResource HighlightBrush}"
                       Margin="6,4,4,4"
                       HorizontalAlignment="Left" VerticalAlignment="Bottom"/>
        </Grid>
    </DataTemplate>

    <Style TargetType="doc:ThumbnailListBox">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="doc:ThumbnailListBox">
                    <ListBox x:Name="ListBox"
                             ItemsSource="{Binding DocumentDataSource.DefaultThumbnailCollection, RelativeSource={RelativeSource TemplatedParent}}"
                             ItemTemplate="{StaticResource ThumbnailTemplate}">
                        <i:Interaction.Behaviors>
                            <doc:PageVirtualizer />
                        </i:Interaction.Behaviors>
                    </ListBox>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="doc:PageNavigator">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="doc:PageNavigator">
                    <StackPanel x:Name="LayoutRoot" Orientation="Horizontal">
                        <TextBox x:Name="PageIndex" Width="36" TextAlignment="Right" Background="Transparent" BorderBrush="Transparent" />
                        <TextBlock Text="/" Style="{StaticResource ContentTextStyle}" VerticalAlignment="Center" Margin="0,0,2,4" />
                        <TextBlock x:Name="PageCount" Style="{StaticResource ContentTextStyle}" Width="44" VerticalAlignment="Center" Margin="0,2,0,4" />
                        <Button x:Name="PreviousPage" Padding="7" ToolTipService.ToolTip="Previous page">
                            <Button.Content>
                                <Image Source="/SampleBrowser;component/Assets/Icons/up.png" />
                            </Button.Content>
                        </Button>
                        <Button x:Name="NextPage" Margin="4,0,0,0" Padding="7" ToolTipService.ToolTip="Next page">
                            <Button.Content>
                                <Image Source="/SampleBrowser;component/Assets/Icons/down.png" />
                            </Button.Content>
                        </Button>
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="doc:HistoryNavigator">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="doc:HistoryNavigator">
                    <StackPanel x:Name="LayoutRoot" Orientation="Horizontal">
                        <Button x:Name="Back" Padding="7" ToolTipService.ToolTip="Navigate backward">
                            <Button.Content>
                                <Image Source="/SampleBrowser;component/Assets/Icons/back.png" />
                            </Button.Content>
                        </Button>
                        <Button x:Name="Forward" Margin="4,0,0,0" Padding="7" ToolTipService.ToolTip="Navigate forward">
                            <Button.Content>
                                <Image Source="/SampleBrowser;component/Assets/Icons/forward.png" />
                            </Button.Content>
                        </Button>
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>